package com.cat.dataStructure02;

class CustomStack {
    static int N = (int)(1e3 + 10), top, max;
    static int[] stack = new int[N];
    public CustomStack(int maxSize) {
        max = maxSize;
        top = 0;
    }

    public void push(int x) {
        if (top < max) {
            stack[top++] = x;
        }
    }

    public int pop() {
        if (top > 0) {
            return stack[--top];
        } else {
            return -1;
        }
    }

    public void increment(int k, int val) {
        for (int i = Math.min(k, top) - 1; i >= 0; i--) {
            stack[i] += val;
        }
    }
}